(function(win) {
	const zzld = {
		// 版本
		version: '1.0.0',

		// 上传 token
		authToken: null,

		//获取设备信息
		getDeviceInfo: function() {
			return win.android.getDeviceInfo()
		},

		// 原生消息提醒
		showToast: function(message) {
			return win.android.showToast(message)
		},

		// 获取地理位置
		locationCallback: function(lng, lat) { // 默认回调方法
			console.log("location: " + lng + " = " + lat)
		},
		getLocation: function(callback) {
			if (callback) {
				this.locationCallback = callback
			}
			win.android.getLocation("zzld.locationCallback")
		},

		// 上传文件
		uploadCallback: function(resp) { // 默认回调方法
			console.log("data:" + JSON.stringify(resp))
		},
		upload: function(callback, token) {
			if (callback) {
				this.uploadCallback = callback
			}
			win.android.upload("zzld.uploadCallback", token)
		},

		// 下载文件
		downloadCallback: function(data) { // 默认回调方法
			console.log("download...." + JSON.stringify(data))
		},
		download: function(callback, url) {
			if (callback) {
				this.downloadCallback = callback
			}
			win.android.download("zzld.downloadCallback", url)
		},

		// 读取身份证信息
		readIdCardCallback: function(data) {
			console.log('================> data:', data)
			alert(data)
		},
		startReadIdCard: function(callback) {
			if (callback) {
				this.readIdCardCallback = callback
			}
			win.android.startReadIdCard()
		},
		// 初始化
		init: function() {
			if (!win.zzld && win.android) {
				window.zzld = zzld;
				console.log('初始化');
			} else if (!win.android) {
				console.log("Is not in android env, can't use this lib.");
			}
		}
	}

	// 初始化
	if (!win.zzld) {
		if (win.android) {
			window.zzld = zzld
		} else {
			console.log("Is not in android env, can't use this lib.")
		}
	}


	// 导出插件以便可以在页面中使用
	if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
		module.exports = zzld;
	} else {
		win.zzld = zzld;
		// zzld.init();
	}
})(window)